package thinking.concurrency;

/**
 * Created by Administrator on 2016/9/7.
 */
public class EvenGenerator extends IntGenerator {
    private int currentEvenValue = 876549;
    @Override
    public synchronized int next() {   // 加入synchronized防止同时访问
        ++currentEvenValue;
        Thread.yield();
        ++currentEvenValue;
        return currentEvenValue;
    }
    public static void main(String[] args) {
        EvenChecker.test(new EvenGenerator());
    }
}
